package com.topnav.mc.admin.entity.wrapper;

import com.topnav.mc.admin.entity.param.AuthorizationParam;
import com.topnav.mc.admin.entity.param.OrganizationParam;
import com.topnav.mc.base.mc.McWrapper;
import org.springframework.util.StringUtils;

/**
 * @Author: kenny
 * @Date: 2024/2/27 10:30
 */
public class AuthorizationWrapper extends McWrapper<AuthorizationParam> {
    public AuthorizationWrapper(AuthorizationParam entity) {
        super(entity);
        //这里要处理当前用户的所有的权限
        if (entity != null){
            if (entity.getId()!=null){this.eq("a.id",entity.getId());}
            if (entity.getParentId()!=null){this.eq("a.parent_id",entity.getParentId());}

            if (!StringUtils.isEmpty(entity.getKeyword())){
                this.and(wrapper -> wrapper.like("a.at_code", entity.getKeyword())
                        .or().like("a.at_name", entity.getKeyword())
                );
            }
            if (entity.getToplayer() != null){
                this.isNull("a.parent_id");
            }
            this.orderByAsc("a.at_path");
        }


    }
}
